import 'package:flutter/material.dart';
import 'package:test1/View/MyRowText.dart';
import 'dart:convert';

class Json_Jar_Page extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return Json_Jar_State();
  }
}

class Json_Jar_State extends State<Json_Jar_Page> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("代码生成库序列化JSON"),
        ),
        body: ListView(
          children: <Widget>[
            MyRowText("代码生成库序列化JSON", () => jsonParser()),
          ],
        ),
      ),
    );
  }

  void jsonParser() {
//    var map = {
//      "name": "zhangsan",
//      "email": "123@qq.com",
//      "age": 1
//    };
//
//    //转成字符串
//    String name = json.encode(map);
//    print(name);
//
//    //解析字符串
//    Map<String, dynamic> user = json.decode(name);
//    print("姓名：${user['name']}");
//    print("邮箱：${user['email']}");
//    print("年龄：${user['age']}");
  }
}